<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    * {
      margin: 0;
      padding: 0;
    }
    
    ul {
      list-style: none;
    }
    #box {
      width: 700px;
      height: 450px;
      border: 1px solid #0f0;
      /* overflow: hidden; */
      margin: 100px auto;
    }
    .con {
      width: 100%;
      height: 100%;
      overflow: hidden;
      position: relative;
    }
    .container {
      width: 400%;
      list-style: none;
      position: absolute;
      left: 0;
      height: 450px;
      transition:left 0.2s linear;
    }
    li {
      display: block;
    }
    .img1 {
      float: left;
      width: 700px;
      height: 450px;
      background-color: #ccc;
    }
    .img2 {
      float: left;
      width: 700px;
      height: 450px;
      background-color: #f00;
    }
    .img3 {
      float: left;
      width: 700px;
      height: 450px;
      background-color: #f0f;
    }
    .img4 {
      float: left;
      width: 700px;
      height: 450px;
      background-color: #0ff;
    }

    .arrow_left,
    .arrow_right {
      position: absolute;
      top: 0;
      bottom: 0;
      /* left: 20px; */
      margin: auto;
      width: 30px;
      height: 30px;
      line-height: 30px;
      text-align: center;
      color: azure;
      border-radius: 50%;
      background-color: #000;
      cursor: pointer;
    }
    .arrow_left {
      left: 20px;
    }
    .arrow_right {
      right: 20px;
    }
  </style>
</head>
<body>
  <div id="box">
    <div class="con">
      <ul class="container">
        <li class="img1">1</li>
        <li class="img2">2</li>
        <li class="img3">3</li>
        <li class="img4">4</li>
      </ul>
      <div class="arrow_left"><</div>
      <div class="arrow_right">></div>
    </div>
    <!-- <div class="img1 swiper_img fl"></div>
    <div class="img2 swiper_img fl"></div>
    <div class="img3 swiper_img fl"></div>
    <div class="img4 swiper_img fl"></div> -->
    
  </div>
  <script src="../JQuery_js/jquery-3.4.1.min.js"></script>
  <script>
    $(function () {
      var a = 700
      var length = $('.container>li').length
      console.log(length);
      
      var index = 0;
      // var container = document.querySelector('.container')
      // console.log(container);
        
        $('.arrow_left').click(function () {
          index++
          if (index == length) {
            index = 0
          }
          var left = -index*a
          if (index<length) {
            $('.container').css('left',`${left}px`)
          }
        })
        $('.arrow_right').click(function () {
          if (index == 0) {
            index = length
          }
          index--
          var left = -index*a
          if (index>=0) {
            $('.container').css('left',`${left}px`)
            
          }
        })
      
      //点击左箭头 图片左移
      
    })
  </script>
</body>
</html>